package com.edu.study.base.stuQuestionPaperRelation.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.stuQuestionPaperRelation.domain.StuQuestionPaperRelation;
import com.edu.study.base.stuQuestionPaperRelation.service.IStuQuestionPaperRelationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 题卷和题库的关系Controller
 * 
 * @author jjt
 * @date 2021-05-29
 */
@RestController
@RequestMapping("/study/stuQuestionPaperRelation")
public class StuQuestionPaperRelationController extends BaseController
{
    @Autowired
    private IStuQuestionPaperRelationService stuQuestionPaperRelationService;

    /**
     * 查询题卷和题库的关系列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuQuestionPaperRelation stuQuestionPaperRelation)
    {
        startPage();
        List<StuQuestionPaperRelation> list = stuQuestionPaperRelationService.selectStuQuestionPaperRelationList(stuQuestionPaperRelation);
        return getDataTable(list);
    }

    /**
     * 导出题卷和题库的关系列表
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:export')")
    @Log(title = "题卷和题库的关系", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuQuestionPaperRelation stuQuestionPaperRelation)
    {
        List<StuQuestionPaperRelation> list = stuQuestionPaperRelationService.selectStuQuestionPaperRelationList(stuQuestionPaperRelation);
        ExcelUtil<StuQuestionPaperRelation> util = new ExcelUtil<StuQuestionPaperRelation>(StuQuestionPaperRelation.class);
        return util.exportExcel(list, "stuQuestionPaperRelation");
    }

    /**
     * 获取题卷和题库的关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuQuestionPaperRelationService.selectStuQuestionPaperRelationById(id));
    }

    /**
     * 新增题卷和题库的关系
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:add')")
    @Log(title = "题卷和题库的关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuQuestionPaperRelation stuQuestionPaperRelation)
    {
        return toAjax(stuQuestionPaperRelationService.insertStuQuestionPaperRelation(stuQuestionPaperRelation));
    }

    /**
     * 修改题卷和题库的关系
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:edit')")
    @Log(title = "题卷和题库的关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuQuestionPaperRelation stuQuestionPaperRelation)
    {
        return toAjax(stuQuestionPaperRelationService.updateStuQuestionPaperRelation(stuQuestionPaperRelation));
    }

    /**
     * 删除题卷和题库的关系
     */
    @PreAuthorize("@ss.hasPermi('study:stuQuestionPaperRelation:remove')")
    @Log(title = "题卷和题库的关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuQuestionPaperRelationService.deleteStuQuestionPaperRelationByIds(ids));
    }
}
